/*
 * 09.10.2008 - Albert Weinert - erstellt.
 * 
 */
using System.Collections.Generic;
using IssueExplorer.Items;
using System.Linq;

namespace IssueExplorer.Repositories
{
    public class RepositoryIssueSelector : IRepositoryIssueSelector
    {
        private readonly IRepository<TrackingItem> itemRepository;

        public RepositoryIssueSelector(IRepository<TrackingItem> itemRepository)
        {
            this.itemRepository = itemRepository;
        }

        public IList<string> Owners
        {
            get
            {
                return (
                           from ti in itemRepository.Entities
                           orderby ti.Owner ascending
                           group ti by ti.Owner into o
                           select o.Key

                          ).ToList();
            }
        }

        public IList<string> Types
        {
            get
            {
                return (
                           from ti in itemRepository.Entities
                           orderby ti.Type ascending
                           group ti by ti.Type into t
                           select t.Key

                          ).ToList();
            }
        }

        public IList<string> Status
        {
            get
            {
                return (
                           from ti in itemRepository.Entities
                           orderby ti.Status ascending
                           group ti by ti.Status into t
                           select t.Key

                          ).ToList();
            }
        }
    }
}